<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function foo() {
        var myName = "一灯"
        let test1 = 1
        const test2 = 2
        var innerBar =
            {
                getName: function () {
                    console.log(test1)
                    return myName
                },
                setName: function (newName) {
                    myName = newName
                }
            }
        return innerBar
    }

    var bar = foo()
    bar.setName('文心一言')
    bar.getName()
    console.log(bar.getName())
</script>
</body>
</html>